Basic Health Areas in Madrid
Now being used for Covid19 restrictions
#!pip install geopandas
#!apt-get install poppler-utils
#!pip install pdf2image
import geopandas
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from pdf2image import convert_from_path, convert_from_bytes
from pdf2image.exceptions import (
PDFInfoNotInstalledError,
PDFPageCountError,
PDFSyntaxError
)
from PIL import Image
df=geopandas.read_file('./maps/zonas_basicas_salud.shp')
df.head()
df.columns
df.info()
plt.hist(df.pob_pad19)
plt.title('Distribution of population by areas')
plt.ylabel('Number of areas')
plt.xlabel('Population');
df.describe()
df[df.pob_pad19==df.pob_pad19.min()]
df[df.pob_pad19==df.pob_pad19.max()]
There are 286 basic health zones, with an average population of around 23_000 people: the Rascafría area has only 2_636 people; the Mar Báltico area has 63_789 people.
df["area"] = df['geometry'].area
df['pob_densidad'] = 100000*df.pob_pad19/df.area
df.head()
fig, (ax1, ax2) = plt.subplots(ncols=2, sharex=True, sharey=True, figsize=(12,6))
df.plot(ax=ax1, column=df.pob_pad19, cmap='Reds', legend=True)
df.plot(ax=ax1, color='white', edgecolor='grey', alpha=0.1)
ax1.set_title('Total population\n by basic health area')
ax1.axis('off')
df.plot(ax=ax2, column=df.pob_densidad, cmap='Reds', legend=True)
df.plot(ax=ax2, color='white', edgecolor='grey', alpha=0.1)
ax2.set_title('Population density\n by basic health area')
ax2.axis('off');
df[df.pob_densidad==df.pob_densidad.min()]
df[df.pob_densidad==df.pob_densidad.max()]
Mapas de Zonas Básicas de Salud del Área Única de la Comunidad de Madrid
https://www.madrid.org/iestadis/fijas/estructu/general/territorio/estructucartemzbs.htm
(maps have been downloaded and stored in ./maps/...)
https://www.madrid.org/iestadis/fijas/estructu/general/territorio/descarga/zbs13_mar_baltico.pdf
# Convert downloaded map from .pdf to .png
#convert_from_path('./maps/zbs13_mar_baltico.pdf')[0].save('./maps/159_mar_baltico.png', dpi=(300,300))
#convert_from_path('./maps/zbs13_rascafria.pdf')[0].save('./maps/222_rascafria.png', dpi=(300,300))
#convert_from_path('./maps/zbs13_martin_de_vargas.pdf')[0].save('./maps/161_martin_de_vargas.png', dpi=(300,300))
Image.open('./maps/222_rascafria.png')